package day11;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class homework03 {
    public static void main(String[] args) throws Exception {
        BufferedReader rw = new BufferedReader(new FileReader("sort.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("sorted.txt"));
        Map<String, String> map = new HashMap<>();
        String a;
        while ((a= rw.readLine()) != null) {
//            System.out.println(a);
            String[] strings = a.split("\\.");
//            System.out.println(Arrays.toString(strings));
            map.put(strings[0], strings[1]);
        }
        Set<Map.Entry<String, String>> set = map.entrySet();
        for (Map.Entry<String, String> entry : set) {
            bw.write(entry.getKey() + "." + entry.getValue());
            bw.newLine();
        }
        bw.close();
        rw.close();
    }
}
